<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width:300px;
            height:300px;
            background-color: red;
        }
        #inner {
            width:100px;
            height:100px;
            background-color: skyblue;
        }
    </style>
</head>
<body>
    <a href="http://baidu.com">百度</a>

    <div id="box">
        <div id="inner">111</div>
    </div>
    <script>
        var aa = document.querySelector('a');
        aa.onclick = function(e){
            e = e || window.event;
            // e.preventDefault();
            console.log('a 标签被点击了');

            // 也可以阻止默认行为
            return false;
        }


        // 测试事件冒泡
        var outer = document.querySelector('#box');
        var inner = document.querySelector('#inner');
        outer.onclick = function(){
            console.log('outer box');
        }
        inner.onclick = function(e){
            console.log('inner click');
            e = e || window.event;
            // e.stopPropagation();
            // return false 不能阻止冒泡
            return false;
        }



    </script>
</body>
</html>